package com.neu.icloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.icloud.entity.Order;
import com.neu.icloud.service.OrderService;

@RestController
@RequestMapping("/OrderController")
public class OrderController {

	@Autowired
	private OrderService orderService;
	
	@RequestMapping("/createOrder")
	public int createOrders(Order orders) throws Exception{
		return orderService.creatOrder(orders);
	}
	
	@RequestMapping("/findOrderById")
	public Order findOrderById(Integer orderId) throws Exception{
		return orderService.findOrderById(orderId);
	}
	
	@RequestMapping("/findOrdersByProductId")
	public int findOrdersByProductId(Integer productId) throws Exception{
		return orderService.findOrdersByProductId(productId);
	}
	
	@RequestMapping("/findAllOrderByFactoryId")
	public List<Order> findAllOrderByFactoryId(Integer factoryId) throws Exception{
		return orderService.findAllOrderByFactoryId(factoryId);
	}
	
	@RequestMapping("/updateOrder")
	public int updateOrder(Order order) throws Exception{
		return orderService.updateOrder(order);
	}
	
	@RequestMapping("/deleteOrderByOrderId")
	public int deleteOrderByOrderId(Integer orderId) throws Exception{
		return orderService.deleteOrderByOrderId(orderId);
	}
}
